$('document').ready(function () {
    // 加载页面时触发的事件
    $('#zj').hover(function () {
        $(this).css('background-color', 'transparent')
    })
    $('#zj1').hover(function () {
        $(this).css('background-color', 'transparent')
    })
    if (getCookie('code') == 200) {

    } else {
        window.location.href = "home.html"
    }
    if ($(window).width() > 1000) {
        $('#Question-Types-content li').css('width', '244px')
        $('#item-bank-checkwrap input').css({
            'width': '13px',
        })
    } else if ($(window).width() < 776) {
        $('#Question-Types-content li').css('width', '88%')
        $('#item-bank-checkwrap input').css({
            'width': '13px',
        })
    }
    // 浏览器分辨率变化时触发的事件
    $(window).resize(function () {
        if ($(window).width() > 1000) {
            $('#Question-Types-content li').css('width', '244px')
            $('#item-bank-checkwrap input').css({
                'width': '13px',
            })
            $('#chapter1 button').css('width', '33%')
        } else if ($(window).width() < 776) {
            $('#Question-Types-content li').css('width', '88%')
            $('#item-bank-checkwrap input').css({
                'width': '13px',
            })
            $('#chapter1 button').css('width', '32%')
        }
    })
    // 加载课程
    $.ajax({
        type: 'GET',
        url: 'http://111.229.120.67/gen/all-course-list',
        xhrFields: {
            withCredentials: true
        },
        success: function (data) {
            if (data.statusCode == 0) {
                var array = data.allcourseList
                for (var i = 0; i < array.length; i++) {
                    if (array[i].ispublic == true) {
                        var course = $('<a href="javascript:void(0)" value="' + array[i].courseid + '"></a>')
                        for (var k = 0; k < array.length; k++) {
                            var cscontent = array[i].name
                        }
                        course.append(cscontent)
                        $('#Question-Types-course').append(course)
                    }

                }
            } else {
                $('#myModal-public').modal({})
                $('#myModal-public h4').html('请求超时')
                $('#myModal-public-body').html('请求超时，请重试')
            }
        }
    })

    // 所属课程的点击事件
    var submitda = 0 //判断用户是否提交过答案
    var courseid = 0
    var item_options_answers = [] //选择题答案
    var item_text_answer = 0 //判断、填空、简答
    $("#Question-Types-course").on('mouseenter', function () {
        $("#Question-Types-course a").off('click').click(function () {
            $('#Question-Types-course a').removeClass('course')
            $('#Question-Types a').removeClass('type')
            $(this).addClass('course')
            courseid = $(this).attr('value')
            clearCookie('item-bank-chapid')
            clearCookie('item-bank-courseid')
            setCookie('item-bank-courseid', courseid)
            zjid = 0
            tmtype = 0
            // 获取题目
            $.ajax({
                type: 'GET',
                url: 'http://111.229.120.67/stu/sjws-ques',
                data: {
                    "course_id": courseid,
                },
                xhrFields: {
                    withCredentials: true
                },
                success: function (data) {
                    if (data.statusCode == 0) {
                        if (data.question !== null) {
                            // 获取章节
                            $.ajax({
                                type: 'POST',
                                url: 'http://111.229.120.67/gen/course-chap',
                                data: {
                                    "cid": courseid,
                                    "pageNum": 1,
                                    "pageSize": 100
                                },
                                xhrFields: {
                                    withCredentials: true
                                },
                                success: function (data) {
                                    if (data.statusCode == 0) {
                                        $('#Question-Types-content').css({
                                            'background-color': 'white',
                                            'border': '1px solid gainsboro'
                                        })
                                        $('#Question-Types').html(`
                                            <a href="javascript:void(0)" value="1">单项选择题</a>
                                            <a href="javascript:void(0)" value="2">多项选择题</a>
                                            <a href="javascript:void(0)" value="3">判断题</a>
                                            <a href="javascript:void(0)" value="4">填空题</a>
                                            <a href="javascript:void(0)" value="5">简答题</a>
                                        `)
                                        var array = data.courseList
                                        $('#Question-Types-chapter').html('') //清除多次点击产生的chapter
                                        for (var i = 0; i < array.length; i++) {
                                            var chapter = $('<a href="javascript:void(0)" value="' + array[i].id + '"></a>')
                                            for (var k = 0; k < array.length; k++) {
                                                var chcontent = array[i].sectionName
                                            }
                                            chapter.append(chcontent)
                                            $('#Question-Types-chapter').append(chapter)
                                        }
                                    } else {
                                        $('#myModal-public').modal({})
                                        $('#myModal-public h4').html('请求超时')
                                        $('#myModal-public-body').html('请求超时，请重试')
                                    }
                                }
                            })
                            // --------
                            submitda = 0
                            var type = data.question.type
                            switch (type) { //所得题目的类型
                                case 1:
                                    item_options_answers = data.question.options_answers
                                    $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（单选题）')
                                    $('#chapter1').html(
                                        `
                                        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="item-bank-checkwrap">

                                        </div>
                                        <button id="item-bank-submit-radio" value="` + data.question.id + `">提交答案</button>
                                        <button id="item-bank-getanswer">查看答案</button>
                                        <button id="item-bank-next">下一题</button>
                                        `
                                    )
                                    var check_num = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
                                    for (var i = 0; i < data.question.options.length; i++) {
                                        $('#item-bank-checkwrap').append(`
                                            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                                <input type="radio" name="answer" value="` + data.question.options[i] + `"> ` + check_num[i] + `：` + data.question.options[i] + `
                                            </div>
                                        `)
                                    }
                                    break
                                case 2:
                                    item_options_answers = data.question.options_answers
                                    $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（多选题）')
                                    $('#chapter1').html(
                                        `
                                        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="item-bank-checkwrap">

                                        </div>
                                        <button id="item-bank-submit-checkbox" value="` + data.question.id + `">提交答案</button>
                                        <button id="item-bank-getanswer">查看答案</button>
                                        <button id="item-bank-next">下一题</button>
                                        `
                                    )
                                    var check_num = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
                                    for (var i = 0; i < data.question.options.length; i++) {
                                        $('#item-bank-checkwrap').append(`
                                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                                    <input type="checkbox" value="` + data.question.options[i] + `"> ` + check_num[i] + `：` + data.question.options[i] + `
                                                </div>
                                            `)
                                    }
                                    break
                                case 3:
                                    item_text_answer = data.question.text_answer
                                    $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（判断题）')
                                    $('#chapter1').html(
                                        `
                                        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="item-bank-checkwrap">
                                        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                        <input type="radio" name="answer-judge" value="t"> 对
                                        </div>
                                        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                        <input type="radio" name="answer-judge" value="f"> 错
                                        </div>
                                        </div>
                                        <button id="item-bank-submit-judge" value="` + data.question.id + `">提交答案</button>
                                        <button id="item-bank-getanswer">查看答案</button>
                                        <button id="item-bank-next">下一题</button>
                                        `
                                    )
                                    break
                                case 4:
                                    item_text_answer = data.question.text_answer
                                    $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（填空题）')
                                    $('#chapter1').html(
                                        `
                                        <textarea style="width:100%;height:160px;margin-top:10px;"></textarea>
                                        <span style="color:gray">用英文的","将答案分隔</span><br>
                                        <button id="item-bank-submit-fill" value="` + data.question.id + `">提交答案</button>
                                        <button id="item-bank-getanswer">查看答案</button>
                                        <button id="item-bank-next">下一题</button>
                                        `
                                    )
                                    break
                                case 5:
                                    item_text_answer = data.question.text_answer
                                    $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（简答题）')
                                    $('#chapter1').html(
                                        `
                                        <textarea style="width:100%;height:160px;margin-top:10px;"></textarea>
                                        <span style="color:gray">用英文的","将答案分隔</span><br>
                                        <button id="item-bank-submit-short" value="` + data.question.id + `">提交答案</button>
                                        <button id="item-bank-getanswer">查看答案</button>
                                        <button id="item-bank-next">下一题</button>
                                        `
                                    )
                                    break
                            }
                        } else {
                            $('#Question-Types').html(`<div style="padding: 4px;margin: 4px;"></div>`)
                            $('#Question-Types-chapter').html(`<div style="padding: 4px;margin: 4px;"></div>`)
                            $('#Question-Types-content').html('')
                            $('#chapter1').html('')
                            $('#Question-Types-content').removeAttr('style')
                            $('#myModal-public').modal({})
                            $('#myModal-public h4').html('未获取到题目')
                            $('#myModal-public-body').html('该课程暂无题目')
                        }
                    } else {
                        $('#myModal-public').modal({})
                        $('#myModal-public h4').html('请求超时')
                        $('#myModal-public-body').html('请求超时，请重试')
                    }
                }
            })
        })
    })
    // 所属章节的点击事件
    var zjid = 0
    $("#Question-Types-chapter").on('mouseenter', function () {
        $("#Question-Types-chapter a").off('click').click(function () {
            clearCookie('item-bank-chapid')
            zjid = $(this).attr('value')
            tmtype = 0
            setCookie('item-bank-chapid', zjid)
            $('#Question-Types-chapter a').removeClass('chapter')
            $('#Question-Types a').removeClass('type')
            $(this).addClass('chapter')
            $.ajax({
                type: 'GET',
                url: 'http://111.229.120.67/stu/sjws-ques',
                data: {
                    "course_id": courseid,
                    "chapter_id": zjid
                },
                xhrFields: {
                    withCredentials: true
                },
                success: function (data) {
                    if (data.statusCode == 0) {
                        if (data.question == null) {
                            $('#Question-Types').html(`<div style="padding: 4px;margin: 4px;"></div>`)
                            $('#Question-Types-content').html('')
                            $('#chapter1').html('')
                            $('#Question-Types-content').removeAttr('style')
                            $('#myModal-public').modal({})
                            $('#myModal-public h4').html('未获取到题目')
                            $('#myModal-public-body').html('该章节暂无题目')
                        } else {
                            $('#Question-Types-content').css({
                                'background-color': 'white',
                                'border': '1px solid gainsboro'
                            })
                            $('#Question-Types').html(`
                                <a href="javascript:void(0)" value="1">单项选择题</a>
                                <a href="javascript:void(0)" value="2">多项选择题</a>
                                <a href="javascript:void(0)" value="3">判断题</a>
                                <a href="javascript:void(0)" value="4">填空题</a>
                                <a href="javascript:void(0)" value="5">简答题</a>
                            `)
                            submitda = 0
                            var type = data.question.type
                            switch (type) { //所得题目的类型
                                case 1:
                                    item_options_answers = data.question.options_answers
                                    $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（单选题）')
                                    $('#chapter1').html(
                                        `
                                        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="item-bank-checkwrap">

                                        </div>
                                        <button id="item-bank-submit-radio" value="` + data.question.id + `">提交答案</button>
                                        <button id="item-bank-getanswer">查看答案</button>
                                        <button id="item-bank-next">下一题</button>
                                        `
                                    )
                                    var check_num = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
                                    for (var i = 0; i < data.question.options.length; i++) {
                                        $('#item-bank-checkwrap').append(`
                                            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                                <input type="radio" name="answer" value="` + data.question.options[i] + `"> ` + check_num[i] + `：` + data.question.options[i] + `
                                            </div>
                                        `)
                                    }
                                    break
                                case 2:
                                    item_options_answers = data.question.options_answers
                                    $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（多选题）')
                                    $('#chapter1').html(
                                        `
                                        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="item-bank-checkwrap">

                                        </div>
                                        <button id="item-bank-submit-checkbox" value="` + data.question.id + `">提交答案</button>
                                        <button id="item-bank-getanswer">查看答案</button>
                                        <button id="item-bank-next">下一题</button>
                                        `
                                    )
                                    var check_num = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
                                    for (var i = 0; i < data.question.options.length; i++) {
                                        $('#item-bank-checkwrap').append(`
                                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                                    <input type="checkbox" value="` + data.question.options[i] + `"> ` + check_num[i] + `：` + data.question.options[i] + `
                                                </div>
                                            `)
                                    }
                                    break
                                case 3:
                                    item_text_answer = data.question.text_answer
                                    $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（判断题）')
                                    $('#chapter1').html(
                                        `
                                        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="item-bank-checkwrap">
                                        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                        <input type="radio" name="answer-judge" value="t"> 对
                                        </div>
                                        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                        <input type="radio" name="answer-judge" value="f"> 错
                                        </div>
                                        </div>
                                        <button id="item-bank-submit-judge" value="` + data.question.id + `">提交答案</button>
                                        <button id="item-bank-getanswer">查看答案</button>
                                        <button id="item-bank-next">下一题</button>
                                        `
                                    )
                                    break
                                case 4:
                                    item_text_answer = data.question.text_answer
                                    $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（填空题）')
                                    $('#chapter1').html(
                                        `
                                        <textarea style="width:100%;height:160px;margin-top:10px;"></textarea>
                                        <span style="color:gray">用英文的","将答案分隔</span><br>
                                        <button id="item-bank-submit-fill" value="` + data.question.id + `">提交答案</button>
                                        <button id="item-bank-getanswer">查看答案</button>
                                        <button id="item-bank-next">下一题</button>
                                        `
                                    )
                                    break
                                case 5:
                                    item_text_answer = data.question.text_answer
                                    $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（简答题）')
                                    $('#chapter1').html(
                                        `
                                        <textarea style="width:100%;height:160px;margin-top:10px;"></textarea>
                                        <span style="color:gray">用英文的","将答案分隔</span><br>
                                        <button id="item-bank-submit-short" value="` + data.question.id + `">提交答案</button>
                                        <button id="item-bank-getanswer">查看答案</button>
                                        <button id="item-bank-next">下一题</button>
                                        `
                                    )
                                    break
                            }
                        }
                    } else {
                        $('#myModal-public').modal({})
                        $('#myModal-public h4').html('请求超时')
                        $('#myModal-public-body').html('请求超时，请重试')
                    }
                }
            })
        })
    });
    // 题目类型点击事件
    var tmtype = 0
    $("#Question-Types").on('mouseenter', function () {
        $("#Question-Types a").off('click').click(function () {
            $('#Question-Types a').removeClass('type')
            $(this).addClass('type')
            tmtype = parseInt($(this).attr('value'))
            if (zjid == 0) {
                $.ajax({
                    type: 'GET',
                    url: 'http://111.229.120.67/stu/sjws-ques',
                    data: {
                        "course_id": courseid,
                        "type": tmtype
                    },
                    xhrFields: {
                        withCredentials: true
                    },
                    success: function (data) {
                        if (data.statusCode == 0) {
                            if (data.question == null) {
                                $('#Question-Types-content').html('')
                                $('#chapter1').html('')
                                $('#Question-Types-content').removeAttr('style')
                                $('#myModal-public').modal({})
                                $('#myModal-public h4').html('未获取到题目')
                                $('#myModal-public-body').html('暂无该类型题目')
                            } else {
                                $('#Question-Types-content').css({
                                    'background-color': 'white',
                                    'border': '1px solid gainsboro'
                                })
                                var type = data.question.type
                                submitda = 0
                                switch (type) { //所得题目的类型
                                    case 1:
                                        item_options_answers = data.question.options_answers
                                        $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（单选题）')
                                        $('#chapter1').html(
                                            `
                                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="item-bank-checkwrap">
        
                                                </div>
                                                <button id="item-bank-submit-radio" value="` + data.question.id + `">提交答案</button>
                                                <button id="item-bank-getanswer">查看答案</button>
                                                <button id="item-bank-next">下一题</button>
                                                `
                                        )
                                        var check_num = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
                                        for (var i = 0; i < data.question.options.length; i++) {
                                            $('#item-bank-checkwrap').append(`
                                                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                                        <input type="radio" name="answer" value="` + data.question.options[i] + `"> ` + check_num[i] + `：` + data.question.options[i] + `
                                                    </div>
                                                `)
                                        }
                                        break
                                    case 2:
                                        item_options_answers = data.question.options_answers
                                        $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（多选题）')
                                        $('#chapter1').html(
                                            `
                                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="item-bank-checkwrap">
        
                                                </div>
                                                <button id="item-bank-submit-checkbox" value="` + data.question.id + `">提交答案</button>
                                                <button id="item-bank-getanswer">查看答案</button>
                                                <button id="item-bank-next">下一题</button>
                                                `
                                        )
                                        var check_num = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
                                        for (var i = 0; i < data.question.options.length; i++) {
                                            $('#item-bank-checkwrap').append(`
                                                        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                                            <input type="checkbox" value="` + data.question.options[i] + `"> ` + check_num[i] + `：` + data.question.options[i] + `
                                                        </div>
                                                    `)
                                        }
                                        break
                                    case 3:
                                        item_text_answer = data.question.text_answer
                                        $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（判断题）')
                                        $('#chapter1').html(
                                            `
                                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="item-bank-checkwrap">
                                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                                <input type="radio" name="answer-judge" value="t"> 对
                                                </div>
                                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                                <input type="radio" name="answer-judge" value="f"> 错
                                                </div>
                                                </div>
                                                <button id="item-bank-submit-judge" value="` + data.question.id + `">提交答案</button>
                                                <button id="item-bank-getanswer">查看答案</button>
                                                <button id="item-bank-next">下一题</button>
                                                `
                                        )
                                        break
                                    case 4:
                                        item_text_answer = data.question.text_answer
                                        $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（填空题）')
                                        $('#chapter1').html(
                                            `
                                                <textarea style="width:100%;height:160px;margin-top:10px;"></textarea>
                                                <span style="color:gray">用英文的","将答案分隔</span><br>
                                                <button id="item-bank-submit-fill" value="` + data.question.id + `">提交答案</button>
                                                <button id="item-bank-getanswer">查看答案</button>
                                                <button id="item-bank-next">下一题</button>
                                                `
                                        )
                                        break
                                    case 5:
                                        item_text_answer = data.question.text_answer
                                        $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（简答题）')
                                        $('#chapter1').html(
                                            `
                                                <textarea style="width:100%;height:160px;margin-top:10px;"></textarea>
                                                <span style="color:gray">用英文的","将答案分隔</span><br>
                                                <button id="item-bank-submit-short" value="` + data.question.id + `">提交答案</button>
                                                <button id="item-bank-getanswer">查看答案</button>
                                                <button id="item-bank-next">下一题</button>
                                                `
                                        )
                                        break
                                }
                            }

                        } else {
                            $('#myModal-public').modal({})
                            $('#myModal-public h4').html('请求超时')
                            $('#myModal-public-body').html('请求超时，请重试')
                        }
                    }
                })
            } else {
                $.ajax({
                    type: 'GET',
                    url: 'http://111.229.120.67/stu/sjws-ques',
                    data: {
                        "course_id": courseid,
                        "chapter_id": zjid,
                        "type": tmtype
                    },
                    xhrFields: {
                        withCredentials: true
                    },
                    success: function (data) {
                        if (data.statusCode == 0) {
                            if (data.question == null) {
                                $('#Question-Types-content').html('')
                                $('#chapter1').html('')
                                $('#Question-Types-content').removeAttr('style')
                                $('#myModal-public').modal({})
                                $('#myModal-public h4').html('未获取到题目')
                                $('#myModal-public-body').html('暂无该类型题目')
                            } else {
                                $('#Question-Types-content').css({
                                    'background-color': 'white',
                                    'border': '1px solid gainsboro'
                                })
                                var type = data.question.type
                                submitda = 0
                                switch (type) { //所得题目的类型
                                    case 1:
                                        item_options_answers = data.question.options_answers
                                        $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（单选题）')
                                        $('#chapter1').html(
                                            `
                                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="item-bank-checkwrap">
        
                                                </div>
                                                <button id="item-bank-submit-radio" value="` + data.question.id + `">提交答案</button>
                                                <button id="item-bank-getanswer">查看答案</button>
                                                <button id="item-bank-next">下一题</button>
                                                `
                                        )
                                        var check_num = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
                                        for (var i = 0; i < data.question.options.length; i++) {
                                            $('#item-bank-checkwrap').append(`
                                                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                                        <input type="radio" name="answer" value="` + data.question.options[i] + `"> ` + check_num[i] + `：` + data.question.options[i] + `
                                                    </div>
                                                `)
                                        }
                                        break
                                    case 2:
                                        item_options_answers = data.question.options_answers
                                        $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（多选题）')
                                        $('#chapter1').html(
                                            `
                                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="item-bank-checkwrap">
        
                                                </div>
                                                <button id="item-bank-submit-checkbox" value="` + data.question.id + `">提交答案</button>
                                                <button id="item-bank-getanswer">查看答案</button>
                                                <button id="item-bank-next">下一题</button>
                                                `
                                        )
                                        var check_num = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
                                        for (var i = 0; i < data.question.options.length; i++) {
                                            $('#item-bank-checkwrap').append(`
                                                        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                                            <input type="checkbox" value="` + data.question.options[i] + `"> ` + check_num[i] + `：` + data.question.options[i] + `
                                                        </div>
                                                    `)
                                        }
                                        break
                                    case 3:
                                        item_text_answer = data.question.text_answer
                                        $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（判断题）')
                                        $('#chapter1').html(
                                            `
                                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="item-bank-checkwrap">
                                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                                <input type="radio" name="answer-judge" value="t"> 对
                                                </div>
                                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                                <input type="radio" name="answer-judge" value="f"> 错
                                                </div>
                                                </div>
                                                <button id="item-bank-submit-judge" value="` + data.question.id + `">提交答案</button>
                                                <button id="item-bank-getanswer">查看答案</button>
                                                <button id="item-bank-next">下一题</button>
                                                `
                                        )
                                        break
                                    case 4:
                                        item_text_answer = data.question.text_answer
                                        $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（填空题）')
                                        $('#chapter1').html(
                                            `
                                                <textarea style="width:100%;height:160px;margin-top:10px;"></textarea>
                                                <span style="color:gray">用英文的","将答案分隔</span><br>
                                                <button id="item-bank-submit-fill" value="` + data.question.id + `">提交答案</button>
                                                <button id="item-bank-getanswer">查看答案</button>
                                                <button id="item-bank-next">下一题</button>
                                                `
                                        )
                                        break
                                    case 5:
                                        item_text_answer = data.question.text_answer
                                        $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（简答题）')
                                        $('#chapter1').html(
                                            `
                                                <textarea style="width:100%;height:160px;margin-top:10px;"></textarea>
                                                <span style="color:gray">用英文的","将答案分隔</span><br>
                                                <button id="item-bank-submit-short" value="` + data.question.id + `">提交答案</button>
                                                <button id="item-bank-getanswer">查看答案</button>
                                                <button id="item-bank-next">下一题</button>
                                                `
                                        )
                                        break
                                }
                            }

                        } else {
                            $('#myModal-public').modal({})
                            $('#myModal-public h4').html('请求超时')
                            $('#myModal-public-body').html('请求超时，请重试')
                        }
                    }
                })
            }

        })
    });
    // 按钮事件
    var options_answers_array = [] //多选题内容
    $('#chapter1').on('mouseenter', function () {
        // 单选题提交
        $('#item-bank-submit-radio').off('click').click(function () {
            _this=$(this)
            if (submitda == 0) {
                if (getCookie('code') == 200) {
                    $.ajax({
                        type: 'POST',
                        url: 'http://111.229.120.67/stu/ans-ques',
                        data: JSON.stringify({
                            "question_id": $('#item-bank-submit-radio').attr('value'),
                            "answer": $('#item-bank-checkwrap input:checked').attr('value')
                        }),
                        xhrFields: {
                            withCredentials: true
                        },
                        contentType: 'application/json',
                        success: function (data) {
                            console.log(data)
                            if (data.statusCode == 0) {
                                _this.html('提交成功')
                                _this.css({
                                    'background-color': 'gainsboro',
                                    'cursor': 'not-allowed'
                                })
                                submitda = 1
                            } else {
                                $('#myModal-public').modal({})
                                $('#myModal-public h4').html('请求超时')
                                $('#myModal-public-body').html('请求超时，请重试')
                            }
                        }
                    })
                    $(this).unbind('click')
                    clearCookie('item-bank-submit')
                    setCookie('item-bank-submit', $(this).attr('value'))
                } else {
                    $('#myModal-public h4').html('权限不足')
                    $('#myModal-public-body').html('您所在的用户组无权使用该功能')
                    $('#myModal-public .modal-footer').html('<button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>')
                    $('#myModal-public').modal({})
                }
            }
        })
        // 多选题提交
        $('#item-bank-submit-checkbox').off('click').click(function () {
            _this=$(this)
            if (submitda == 0) {
                if (getCookie('code') == 200) {
                    for (var k = 0; k < $('#item-bank-checkwrap input:checked').length; k++) {
                        options_answers_array[k] = $('#item-bank-checkwrap input:checked').eq(k).attr('value')
                    }
                    console.log($('#item-bank-submit-checkbox').attr('value'))
                    console.log(options_answers_array)
                    $.ajax({
                        type: 'POST',
                        url: 'http://111.229.120.67/stu/ans-ques',
                        data: JSON.stringify({
                            "question_id": $('#item-bank-submit-checkbox').attr('value'),
                            "answers": options_answers_array
                        }),
                        xhrFields: {
                            withCredentials: true
                        },
                        contentType: 'application/json',
                        success: function (data) {
                            console.log(data)
                            if (data.statusCode == 0) {
                                _this.html('提交成功')
                                _this.css({
                                    'background-color': 'gainsboro',
                                    'cursor': 'not-allowed'
                                })
                                submitda = 1
                            } else {
                                $('#myModal-public').modal({})
                                $('#myModal-public h4').html('请求超时')
                                $('#myModal-public-body').html('请求超时，请重试')
                            }
                        }
                    })
                    $(this).unbind('click')
                    clearCookie('item-bank-submit')
                    setCookie('item-bank-submit', $(this).attr('value'))
                } else {
                    $('#myModal-public h4').html('权限不足')
                    $('#myModal-public-body').html('您所在的用户组无权使用该功能')
                    $('#myModal-public .modal-footer').html('<button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>')
                    $('#myModal-public').modal({

                    })
                }
            }
        })
        // 判断题提交
        $('#item-bank-submit-judge').off('click').click(function () {
            _this=$(this)
            if (submitda == 0) {
                if (getCookie('code') == 200) {
                    $.ajax({
                        type: 'POST',
                        url: 'http://111.229.120.67/stu/ans-ques',
                        data: JSON.stringify({
                            "question_id": $('#item-bank-submit-judge').attr('value'),
                            "answer": $('#item-bank-checkwrap input:checked').attr('value')
                        }),
                        xhrFields: {
                            withCredentials: true
                        },
                        contentType: 'application/json',
                        success: function (data) {
                            console.log(data)
                            if (data.statusCode == 0) {
                                _this.html('提交成功')
                                _this.css({
                                    'background-color': 'gainsboro',
                                    'cursor': 'not-allowed'
                                })
                                submitda = 1
                            } else {
                                $('#myModal-public').modal({})
                                $('#myModal-public h4').html('请求超时')
                                $('#myModal-public-body').html('请求超时，请重试')
                            }
                        }
                    })


                    $(this).unbind('click')
                    clearCookie('item-bank-submit')
                    setCookie('item-bank-submit', $(this).attr('value'))
                } else {
                    $('#myModal-public h4').html('权限不足')
                    $('#myModal-public-body').html('您所在的用户组无权使用该功能')
                    $('#myModal-public .modal-footer').html('<button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>')
                    $('#myModal-public').modal({

                    })
                }
            }
        })
        // 填空题提交
        $('#item-bank-submit-fill').off('click').click(function () {
            _this=$(this)
            if (submitda == 0) {
                if (getCookie('code') == 200) {
                    $.ajax({
                        type: 'POST',
                        url: 'http://111.229.120.67/stu/ans-ques',
                        data: JSON.stringify({
                            "question_id": $('#item-bank-submit-fill').attr('value'),
                            "answer": $('#chapter1 textarea').val()
                        }),
                        xhrFields: {
                            withCredentials: true
                        },
                        contentType: 'application/json',
                        success: function (data) {
                            console.log(data)
                            if (data.statusCode == 0) {
                                _this.html('提交成功')
                                _this.css({
                                    'background-color': 'gainsboro',
                                    'cursor': 'not-allowed'
                                })
                                submitda = 1
                            } else {
                                $('#myModal-public').modal({})
                                $('#myModal-public h4').html('请求超时')
                                $('#myModal-public-body').html('请求超时，请重试')
                            }
                        }
                    })


                    $(this).unbind('click')
                    clearCookie('item-bank-submit')
                    setCookie('item-bank-submit', $(this).attr('value'))
                } else {
                    $('#myModal-public h4').html('权限不足')
                    $('#myModal-public-body').html('您所在的用户组无权使用该功能')
                    $('#myModal-public .modal-footer').html('<button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>')
                    $('#myModal-public').modal({

                    })
                }
            }
        })
        // 简答题提交
        $('#item-bank-submit-short').off('click').click(function () {
            _this=$(this)
            if (submitda == 0) {
                if (getCookie('code') == 200) {
                    $.ajax({
                        type: 'POST',
                        url: 'http://111.229.120.67/stu/ans-ques',
                        data: JSON.stringify({
                            "question_id": $('#item-bank-submit-short').attr('value'),
                            "answer": $('#chapter1 textarea').val()
                        }),
                        xhrFields: {
                            withCredentials: true
                        },
                        contentType: 'application/json',
                        success: function (data) {
                            console.log(data)
                            if (data.statusCode == 0) {
                                _this.html('提交成功')
                                _this.css({
                                    'background-color': 'gainsboro',
                                    'cursor': 'not-allowed'
                                })
                                submitda = 1
                            } else {
                                $('#myModal-public').modal({})
                                $('#myModal-public h4').html('请求超时')
                                $('#myModal-public-body').html('请求超时，请重试')
                            }
                        }
                    })


                    $(this).unbind('click')
                    clearCookie('item-bank-submit')
                    setCookie('item-bank-submit', $(this).attr('value'))
                } else {
                    $('#myModal-public h4').html('权限不足')
                    $('#myModal-public-body').html('您所在的用户组无权使用该功能')
                    $('#myModal-public .modal-footer').html('<button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>')
                    $('#myModal-public').modal({

                    })
                }
            }
        })

        // 查看答案
        $('#item-bank-getanswer').off('click').click(function () {
            if ($('#item-bank-submit-radio').html() == '提交成功') {
                var array=['A','B','C','D','E','F','G']
                $('#myModal-public h4').html('参考答案')
                $('#myModal-public-body').html('该题正确答案为：' + array[item_options_answers] + '')
                $('#myModal-public .modal-footer').html('<button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>')
                $('#myModal-public').modal({})
            } else if ($('#item-bank-submit-checkbox').html() == '提交成功') {
                var array_length=item_options_answers.length
                var array=item_options_answers
                for (var i = 0; i < array_length; i++) {
                    if(array[i]==0){
                        array[i]='A'
                    }else if(array[i]==1){
                        array[i]='B'
                    }else if(array[i]==2){
                        array[i]='C'
                    }else if(array[i]==3){
                        array[i]='D'
                    }else if(array[i]==4){
                        array[i]='E'
                    }else if(array[i]==5){
                        array[i]='F'
                    }else if(array[i]==6){
                        array[i]='G'
                    }
                }
                $('#myModal-public h4').html('参考答案')
                $('#myModal-public-body').html('该题正确答案为：' + array + '')
                $('#myModal-public .modal-footer').html('<button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>')
                $('#myModal-public').modal({})
            } else if ($('#item-bank-submit-judge').html() == '提交成功') {
                if(item_text_answer=='t'){
                    $('#myModal-public h4').html('参考答案')
                    $('#myModal-public-body').html('该题正确答案为：对')
                    $('#myModal-public .modal-footer').html('<button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>')
                    $('#myModal-public').modal({})
                }else if(item_text_answer=='f'){
                    $('#myModal-public h4').html('参考答案')
                    $('#myModal-public-body').html('该题正确答案为：错')
                    $('#myModal-public .modal-footer').html('<button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>')
                    $('#myModal-public').modal({})
                }    
            } else if ($('#item-bank-submit-fill').html() == '提交成功') {
                $('#myModal-public h4').html('参考答案')
                $('#myModal-public-body').html('该题正确答案为：' + item_text_answer + '')
                $('#myModal-public .modal-footer').html('<button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>')
                $('#myModal-public').modal({})
            } else if ($('#item-bank-submit-short').html() == '提交成功') {
                $('#myModal-public h4').html('参考答案')
                $('#myModal-public-body').html('该题正确答案为：' + item_text_answer + '')
                $('#myModal-public .modal-footer').html('<button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>')
                $('#myModal-public').modal({})
            } else {
                $('#myModal-public h4').html('未提交答案')
                $('#myModal-public-body').html('没作答前不能查看参考答案')
                $('#myModal-public .modal-footer').html('<button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>')
                $('#myModal-public').modal({

                })
            }
        })
        // 下一题
        $('#item-bank-next').off('click').click(function () {
            if (getCookie('code') == 200) {
                if (zjid == 0 && tmtype == 0) {
                    $.ajax({
                        type: 'GET',
                        url: 'http://111.229.120.67/stu/sjws-ques',
                        data: {
                            "course_id": courseid,
                        },
                        xhrFields: {
                            withCredentials: true
                        },
                        success: function (data) {
                            if (data.statusCode == 0) {
                                submitda = 0
                                var type = data.question.type
                                switch (type) { //所得题目的类型
                                    case 1:
                                        item_options_answers = data.question.options_answers
                                        $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（单选题）')
                                        $('#chapter1').html(
                                            `
                                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="item-bank-checkwrap">
        
                                                </div>
                                                <button id="item-bank-submit-radio" value="` + data.question.id + `">提交答案</button>
                                                <button id="item-bank-getanswer">查看答案</button>
                                                <button id="item-bank-next">下一题</button>
                                                `
                                        )
                                        var check_num = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
                                        for (var i = 0; i < data.question.options.length; i++) {
                                            $('#item-bank-checkwrap').append(`
                                                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                                        <input type="radio" name="answer" value="` + data.question.options[i] + `"> ` + check_num[i] + `：` + data.question.options[i] + `
                                                    </div>
                                                `)
                                        }
                                        break
                                    case 2:
                                        item_options_answers = data.question.options_answers
                                        $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（多选题）')
                                        $('#chapter1').html(
                                            `
                                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="item-bank-checkwrap">
        
                                                </div>
                                                <button id="item-bank-submit-checkbox" value="` + data.question.id + `">提交答案</button>
                                                <button id="item-bank-getanswer">查看答案</button>
                                                <button id="item-bank-next">下一题</button>
                                                `
                                        )
                                        var check_num = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
                                        for (var i = 0; i < data.question.options.length; i++) {
                                            $('#item-bank-checkwrap').append(`
                                                        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                                            <input type="checkbox" value="` + data.question.options[i] + `"> ` + check_num[i] + `：` + data.question.options[i] + `
                                                        </div>
                                                    `)
                                        }
                                        break
                                    case 3:
                                        item_text_answer = data.question.text_answer
                                        $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（判断题）')
                                        $('#chapter1').html(
                                            `
                                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="item-bank-checkwrap">
                                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                                <input type="radio" name="answer-judge" value="t"> 对
                                                </div>
                                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                                <input type="radio" name="answer-judge" value="f"> 错
                                                </div>
                                                </div>
                                                <button id="item-bank-submit-judge" value="` + data.question.id + `">提交答案</button>
                                                <button id="item-bank-getanswer">查看答案</button>
                                                <button id="item-bank-next">下一题</button>
                                                `
                                        )
                                        break
                                    case 4:
                                        item_text_answer = data.question.text_answer
                                        $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（填空题）')
                                        $('#chapter1').html(
                                            `
                                                <textarea style="width:100%;height:160px;margin-top:10px;"></textarea>
                                                <span style="color:gray">用英文的","将答案分隔</span><br>
                                                <button id="item-bank-submit-fill" value="` + data.question.id + `">提交答案</button>
                                                <button id="item-bank-getanswer">查看答案</button>
                                                <button id="item-bank-next">下一题</button>
                                                `
                                        )
                                        break
                                    case 5:
                                        item_text_answer = data.question.text_answer
                                        $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（简答题）')
                                        $('#chapter1').html(
                                            `
                                                <textarea style="width:100%;height:160px;margin-top:10px;"></textarea>
                                                <span style="color:gray">用英文的","将答案分隔</span><br>
                                                <button id="item-bank-submit-short" value="` + data.question.id + `">提交答案</button>
                                                <button id="item-bank-getanswer">查看答案</button>
                                                <button id="item-bank-next">下一题</button>
                                                `
                                        )
                                        break
                                }
                            } else {
                                $('#myModal-public').modal({})
                                $('#myModal-public h4').html('请求超时')
                                $('#myModal-public-body').html('请求超时，请重试')
                            }
                        }
                    })
                } else if (tmtype == 0) {
                    $.ajax({
                        type: 'GET',
                        url: 'http://111.229.120.67/stu/sjws-ques',
                        data: {
                            "course_id": courseid,
                            "chapter_id": zjid
                        },
                        xhrFields: {
                            withCredentials: true
                        },
                        success: function (data) {
                            console.log({
                                "course_id": courseid,
                                "chapter_id": zjid
                            })
                            if (data.statusCode == 0) {
                                submitda = 0
                                var type = data.question.type
                                switch (type) { //所得题目的类型
                                    case 1:
                                        item_options_answers = data.question.options_answers
                                        $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（单选题）')
                                        $('#chapter1').html(
                                            `
                                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="item-bank-checkwrap">
        
                                                </div>
                                                <button id="item-bank-submit-radio" value="` + data.question.id + `">提交答案</button>
                                                <button id="item-bank-getanswer">查看答案</button>
                                                <button id="item-bank-next">下一题</button>
                                                `
                                        )
                                        var check_num = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
                                        for (var i = 0; i < data.question.options.length; i++) {
                                            $('#item-bank-checkwrap').append(`
                                                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                                        <input type="radio" name="answer" value="` + data.question.options[i] + `"> ` + check_num[i] + `：` + data.question.options[i] + `
                                                    </div>
                                                `)
                                        }
                                        break
                                    case 2:
                                        item_options_answers = data.question.options_answers
                                        $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（多选题）')
                                        $('#chapter1').html(
                                            `
                                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="item-bank-checkwrap">
        
                                                </div>
                                                <button id="item-bank-submit-checkbox" value="` + data.question.id + `">提交答案</button>
                                                <button id="item-bank-getanswer">查看答案</button>
                                                <button id="item-bank-next">下一题</button>
                                                `
                                        )
                                        var check_num = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
                                        for (var i = 0; i < data.question.options.length; i++) {
                                            $('#item-bank-checkwrap').append(`
                                                        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                                            <input type="checkbox" value="` + data.question.options[i] + `"> ` + check_num[i] + `：` + data.question.options[i] + `
                                                        </div>
                                                    `)
                                        }
                                        break
                                    case 3:
                                        item_text_answer = data.question.text_answer
                                        $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（判断题）')
                                        $('#chapter1').html(
                                            `
                                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="item-bank-checkwrap">
                                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                                <input type="radio" name="answer-judge" value="t"> 对
                                                </div>
                                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                                <input type="radio" name="answer-judge" value="f"> 错
                                                </div>
                                                </div>
                                                <button id="item-bank-submit-judge" value="` + data.question.id + `">提交答案</button>
                                                <button id="item-bank-getanswer">查看答案</button>
                                                <button id="item-bank-next">下一题</button>
                                                `
                                        )
                                        break
                                    case 4:
                                        item_text_answer = data.question.text_answer
                                        $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（填空题）')
                                        $('#chapter1').html(
                                            `
                                                <textarea style="width:100%;height:160px;margin-top:10px;"></textarea>
                                                <span style="color:gray">用英文的","将答案分隔</span><br>
                                                <button id="item-bank-submit-fill" value="` + data.question.id + `">提交答案</button>
                                                <button id="item-bank-getanswer">查看答案</button>
                                                <button id="item-bank-next">下一题</button>
                                                `
                                        )
                                        break
                                    case 5:
                                        item_text_answer = data.question.text_answer
                                        $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（简答题）')
                                        $('#chapter1').html(
                                            `
                                                <textarea style="width:100%;height:160px;margin-top:10px;"></textarea>
                                                <span style="color:gray">用英文的","将答案分隔</span><br>
                                                <button id="item-bank-submit-short" value="` + data.question.id + `">提交答案</button>
                                                <button id="item-bank-getanswer">查看答案</button>
                                                <button id="item-bank-next">下一题</button>
                                                `
                                        )
                                        break
                                }
                            } else {
                                $('#myModal-public').modal({})
                                $('#myModal-public h4').html('请求超时')
                                $('#myModal-public-body').html('请求超时，请重试')
                            }
                        }
                    })
                } else {
                    $.ajax({
                        type: 'GET',
                        url: 'http://111.229.120.67/stu/sjws-ques',
                        data: {
                            "course_id": courseid,
                            "chapter_id": zjid,
                            "type": tmtype
                        },
                        xhrFields: {
                            withCredentials: true
                        },
                        success: function (data) {
                            // console.log(data)
                            if (data.statusCode == 0) {
                                if (data.question == null) {
                                    $('#myModal-public').modal({})
                                    $('#myModal-public h4').html('未获取到题目')
                                    $('#myModal-public-body').html('没有更多该条件下的题目了')
                                } else {
                                    var type = data.question.type
                                    submitda = 0
                                    switch (type) { //所得题目的类型
                                        case 1:
                                            item_options_answers = data.question.options_answers
                                            $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（单选题）')
                                            $('#chapter1').html(
                                                `
                                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="item-bank-checkwrap">
        
                                                </div>
                                                <button id="item-bank-submit-radio" value="` + data.question.id + `">提交答案</button>
                                                <button id="item-bank-getanswer">查看答案</button>
                                                <button id="item-bank-next">下一题</button>
                                                `
                                            )
                                            var check_num = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
                                            for (var i = 0; i < data.question.options.length; i++) {
                                                $('#item-bank-checkwrap').append(`
                                                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                                        <input type="radio" name="answer" value="` + data.question.options[i] + `"> ` + check_num[i] + `：` + data.question.options[i] + `
                                                    </div>
                                                `)
                                            }
                                            break
                                        case 2:
                                            item_options_answers = data.question.options_answers
                                            $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（多选题）')
                                            $('#chapter1').html(
                                                `
                                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="item-bank-checkwrap">
        
                                                </div>
                                                <button id="item-bank-submit-checkbox" value="` + data.question.id + `">提交答案</button>
                                                <button id="item-bank-getanswer">查看答案</button>
                                                <button id="item-bank-next">下一题</button>
                                                `
                                            )
                                            var check_num = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
                                            for (var i = 0; i < data.question.options.length; i++) {
                                                $('#item-bank-checkwrap').append(`
                                                        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                                            <input type="checkbox" value="` + data.question.options[i] + `"> ` + check_num[i] + `：` + data.question.options[i] + `
                                                        </div>
                                                    `)
                                            }
                                            break
                                        case 3:
                                            item_text_answer = data.question.text_answer
                                            $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（判断题）')
                                            $('#chapter1').html(
                                                `
                                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="item-bank-checkwrap">
                                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                                <input type="radio" name="answer-judge" value="t"> 对
                                                </div>
                                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                                <input type="radio" name="answer-judge" value="f"> 错
                                                </div>
                                                </div>
                                                <button id="item-bank-submit-judge" value="` + data.question.id + `">提交答案</button>
                                                <button id="item-bank-getanswer">查看答案</button>
                                                <button id="item-bank-next">下一题</button>
                                                `
                                            )
                                            break
                                        case 4:
                                            item_text_answer = data.question.text_answer
                                            $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（填空题）')
                                            $('#chapter1').html(
                                                `
                                                <textarea style="width:100%;height:160px;margin-top:10px;"></textarea>
                                                <span style="color:gray">用英文的","将答案分隔</span><br>
                                                <button id="item-bank-submit-fill" value="` + data.question.id + `">提交答案</button>
                                                <button id="item-bank-getanswer">查看答案</button>
                                                <button id="item-bank-next">下一题</button>
                                                `
                                            )
                                            break
                                        case 5:
                                            item_text_answer = data.question.text_answer
                                            $('#Question-Types-content').html('<p style="font-size:20px;margin:4px">' + data.question.content + '（简答题）')
                                            $('#chapter1').html(
                                                `
                                                <textarea style="width:100%;height:160px;margin-top:10px;"></textarea>
                                                <span style="color:gray">用英文的","将答案分隔</span><br>
                                                <button id="item-bank-submit-short" value="` + data.question.id + `">提交答案</button>
                                                <button id="item-bank-getanswer">查看答案</button>
                                                <button id="item-bank-next">下一题</button>
                                                `
                                            )
                                            break
                                    }
                                }

                            } else {
                                $('#myModal-public').modal({})
                                $('#myModal-public h4').html('请求超时')
                                $('#myModal-public-body').html('请求超时，请重试')
                            }
                        }
                    })

                }

            } else {
                $('#myModal-public h4').html('权限不足')
                $('#myModal-public-body').html('您所在的用户组无权使用该功能')
                $('#myModal-public .modal-footer').html('<button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>')
                $('#myModal-public').modal({

                })
            }
        })

    })

    // 查看正确率
    $('#find-acc').off('click').click(function () {
        $.ajax({
            type: 'GET',
            url: 'http://111.229.120.67/stu/find-acc',
            xhrFields: {
                withCredentials: true
            },
            success: function (data) {
                // console.log(data)
                if (data.statusCode == 0) {
                    $('#myModal-public h4').html('查看刷题正确率')
                    $('#myModal-public-body').html('您的正确率为：' + data.acc + '')
                    $('#myModal-public').modal({})
                } else {
                    $('#myModal-public').modal({})
                    $('#myModal-public h4').html('请求超时')
                    $('#myModal-public-body').html('请求超时，请重试')
                }
            }
        })
    })
})